
Ext.define('Writer.Fases', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
    },{
        name: 'nroItems',
        type: 'int',
    },{
        name: 'idProyectoFase',
        type: 'int',
    },{
        name: 'nroLBs',
        type: 'int',
    },{
        name: 'posicionFase',
        type: 'int',
    }, 'nombreFase', 'descripcion', 'estado']
});

Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', 'static/ux');

Ext.define('desarrollo.FaseGrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.fasesgrid',
    requires: [
        'Ext.grid.plugin.CellEditing',
        'Ext.form.field.Text',
        'Ext.ux.grid.FiltersFeature',
        'Ext.toolbar.TextItem'
    ],
    initComponent: function(){
        this.editing = Ext.create('Ext.grid.plugin.CellEditing');
        
		var filters = {
			ftype: 'filters',
			local: true,

		};

        Ext.apply(this, {
            iconCls: 'icon-grid',
            //frame: true,
            plugins: [this.editing],
            features: [filters],
            dockedItems: [{ 
                weight: 1,
                xtype: 'toolbar',
                dock: 'bottom',
                items: ['->',{
                    iconCls: 'icon-refresh',
                    text: '<b>Actualizar</b>',
                    scope: this,
                    handler: this.onRefresh
                },{
                    iconCls: 'icon-salir',
                    text: '<b>Proyectos</b>',
                    scope: this,
                    handler: this.onSalir
                }]
            }],
            columns: [{
                text: 'IdProy',
                width: 30,
                filter: true,
                hidden: true,
                dataIndex: 'idProyectoFase'
            },{
                text: 'Id',
                width: 30,
                hidden: true,
                filter: true,
                dataIndex: 'id'
            },{
                header: '<b>Nombre</b>',
                flex: 1,
                filter: true,
                dataIndex: 'nombreFase',

            }, {
                header: '<b>Descripcion</b>',
                width: 140,
                filter: true,
                dataIndex: 'descripcion',

            },{
                text: '<b>Posicion</b>',
                width: 80,
                dataIndex: 'posicionFase'
            },{
                text: '<b>Nº Items</b>',
                width: 80,
                filter: true,
                dataIndex: 'nroItems'
            },{
                text: '<b>Nº LBs</b>',
                width: 80,
                filter: true,
                dataIndex: 'nroLBs'
            }, {
                header: '<b>Estado</b>',
                flex: 1,
                filter: true,
                dataIndex: 'estado',

            }]
        });
        this.callParent();
        this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
    },   

    onRefresh: function(){
		this.getSelectionModel().clearSelections();
		this.store.load();
	},
	
	 onSalir: function(){
		 
		this.fireEvent('salir');
	},
	
});
